import { ChatMessage } from "./message";
import { RefObject } from "react";
import { Message } from "./chat.d";
type Props = {
  messages: Array<Message>;
  setCurrentArtifact: (data: any) => void;
  containerRef: RefObject<HTMLDivElement>;
  generateFileClick: (data: any) => void;
};

export const ChatMessageList = ({
  messages,
  setCurrentArtifact,
  containerRef,
  generateFileClick
}: Props) => {
  return (
    <div
      ref={containerRef}
      className="flex-1 flex flex-col gap-4 max-w-3xl mx-auto w-full pt-1"
    >
      {messages.map((message, index) => (
        <div key={index}>
          <ChatMessage
            role={message.role}
            text={message.content}
            attachments={message?.experimental_attachments || []}
            setCurrentArtifact={setCurrentArtifact}
            generateFileClick={generateFileClick}
          />
        </div>


        // <>

        //   {/* 不知道为什么要加这个 */}
        //   {/* {index !== messages.length - 1 && <div>未知状态</div>} */}
        // </>
      ))}
    </div>
  );
};
